<template>
    <div>
        {{data}}
        <span>{{ id }}</span>
        <h2>{{info.category}}类目下的文章列表</h2>
        <router-link to="/cs">返回首页</router-link>
        <div v-for="(item,index) in info.blogs" >

        <router-link :to="'/cs/'+id+'/'+item.id">{{item.title}}</router-link>
        </div>
    </div>
</template>

<script>
    import {mapState} from "vuex"
    export default {
        name: "cs2",
        data(){
            return{
                info:{}
            }
        },
        props:['id'],
        computed:{
            //把tata数据克隆给mapState
            ...mapState(["data"])
        },
        created() {
        //试着通过id去查找数据找到了赋值给this.info
            this.info=this.data.category.find(r=>r.id===parseInt(this.id))
        }
    }
</script>

<style scoped>

</style>
